<%@page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/vendor/bootstrap/css/bootstrap.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/vendor/font-awesome/css/font-awesome.min.css">
    <!-- Custom Font Icons CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/layer.css">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/custom.css">
    <title>文章详情</title>
    <style>
        .myList li{
            display: inline-block;
        }
    </style>
</head>
<body>
<%@include file="../publicjsp/head.jsp"%>

<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <nav id="sidebar">
        <!-- Sidebar Header-->
        <%@ include file="../publicjsp/sidhead.jsp"%>
        <!-- Sidebar Navidation Menus--><span class="heading">Main</span>
        <%@ include file="../publicjsp/sidenav.jsp"%>

    </nav>
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">文章详情</h2>
            </div>
        </div>

        <section class="no-padding-bottom">

                <div class="myTitle">
                    <h3 class="text-center">${mapList.title}</h3>

                    <c:if test="${mapList.uId == mapList.u_id && mapList.uId != null || mapList.u_id != null}">
                        <input onclick="cancel('${mapList.id}','${mapList.u_id}')" type="submit" value="取消收藏" class="btn btn-info">
                    </c:if>
                    <c:if test="${mapList.uId != mapList.u_id && mapList.uId == null || mapList.u_id == null}">
                        <input onclick="add('${mapList.id}','${mapList.u_id}')" type="submit" value="添加收藏" class="btn btn-info">
                    </c:if>

                </div>

                <div class="myContent">
                    <p class="h6"><strong>发布人：</strong>${mapList.publish_username}</p>
                    <p class="h6"><strong>创建时间：</strong>${mapList.publish_date}</p>
                    <p class="h6"><strong>浏览次数：</strong>${mapList.browse_count}</p>
                    <p class="h6"><strong>收藏次数：</strong>${mapList.ArticleCount}</p>
                    <textarea style="padding: 2px" disabled="disabled" class="form-control" rows="11">${mapList.content}</textarea>
                </div>
            <div class="myList">
                <p>您关注的小伙伴等人也收藏了该文章</p>
                <ul>
                    <li class="list-group-item">
                        <a href="#">小东</a>
                    </li>
                    <li class="list-group-item">
                        <a href="#">小标</a>
                    </li>

                </ul>
            </div>
        </section>

        <%@include file="../publicjsp/footer.jsp"%>
    </div>
</div>

<!-- JavaScript files-->
<script src="${pageContext.request.contextPath}/vendor/jquery/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/vendor/popper.js/umd/popper.min.js"> </script>
<script src="${pageContext.request.contextPath}/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/vendor/jquery.cookie/jquery.cookie.js"> </script>
<script src="${pageContext.request.contextPath}/vendor/chart.js/Chart.min.js"></script>
<script src="${pageContext.request.contextPath}/vendor/jquery-validation/jquery.validate.min.js"></script>
<script src="${pageContext.request.contextPath}/js/charts-home.js"></script>
<script src="${pageContext.request.contextPath}/js/front.js"></script>
<script src="${pageContext.request.contextPath}/js/layer.js"></script>
<script src="${pageContext.request.contextPath}/js/custom.js"></script>

<script>
    function add(id,uId) {
        console.log("id="+id);
        console.log("uId="+uId);
        $.post('${pageContext.request.contextPath}/article/AddCollection',{id:id,uId:uId},function (data) {
            if (data === "1"){
                // console.log(data);
                // layer.msg("添加收藏成功");
                alert("添加收藏成功");
                // $(this).prop("value","取消收藏");
                $(this).attr("value","取消收藏");
                dis
                setTimeout(function () {
                    location.reload();
                },100);
                $(this).attr("value","取消收藏");

            } else {
                // console.log(data);
                location.reload();
                // layer.msg(data);
                alert(data);
            }
        });
    }
    function cancel(id,uId) {
        console.log(id);
        console.log(uId);
        $.post('${pageContext.request.contextPath}/article/DeleteCollection',{id:id,uId:uId},function (data) {
            console.log(data);
            if (data === "1"){
                location.reload();
                // layer.msg("取消收藏成功");
                alert("取消收藏成功");
                $(this).attr("value","添加收藏");

            } else {
                location.reload();
                // layer.msg(data);
                alert(data);
            }
        });
    }
</script>

</body>
</html>